<?php


namespace App\Commons\Domain\Module\Exchange\Model;

use \App\Commons\Domain\Module\Exchange\Model\Advertising;
use App\Commons\Domain\Core\Model;
use App\Commons\Domain\Module\UserCenter\Model\Member;


/**
 * App\Commons\Domain\Module\Exchange\Model\Order
 *
 * @property int $id
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @property string $order_no 订单号
 * @property int $advertising_id 广告id
 * @property string $price 单价
 * @property string $quantity 数量
 * @property int $payment_id 收款方式id
 * @property int $status 订单状态:1.进行中、2.完成、3取消、4买方支付超时、5卖方放币超时
 * @property string|null $trader_uid 交易方uid
 * @property string|null $pay_at 买方付款时间
 * @property string|null $put_at 卖方放币时间
 * @property-read Advertising $advertising
 * @property-read Member|null $traderUid
 * @method static \Illuminate\Database\Eloquent\Builder|Order newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Order newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Order query()
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereAdvertisingId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereOrderNo($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order wherePayAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order wherePaymentId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order wherePrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order wherePutAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereQuantity($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereTraderUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Order whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class Order extends Model
{
    /**
     * 订单归属广告
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function advertising()
    {
        return $this->belongsTo(Advertising::class, 'advertising_id', 'id');
    }

    /**
     * 所属交易发起者
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function traderUid()
    {
        return $this->belongsTo(Member::class, 'trader_uid', 'uid');
    }

}
